var ns;
var app = new Vue({
    el: '#app',
    data: {
        passwordtype: 0,
        oldPassword:'',
        form: {
            id: '',
            password: '',
            newpassword: '',
        }
    },
    methods: {


        do_editpassword: function() {
            var that = this;
            // alert(that.form.id);
            //获取输入的密码，调用接口保存密码
            if (that.form.password == '') {
                api.toast({
                    msg: '请输入新密码',
                    duration: 2000,
                    location: 'bottom'
                });
                return;
            }
            if (that.form.newpassword == '') {
                api.toast({
                    msg: '请再次输入新密码',
                    duration: 2000,
                    location: 'bottom'
                });
                return;
            }
            if (that.form.newpassword != that.form.password) {
                api.toast({
                    msg: '两次输入的密码不一致',
                    duration: 2000,
                    location: 'bottom'
                });
                return;
            }
            var opt = {
                action: 'forgetsavenewpassword',
                username: that.form.id,
                usertype: "APPBusiness",
                newpassword: that.form.newpassword
            };
            ns.post(opt, function(succeed, data, err) {
                if (succeed) {
                    //成功
                    api.toast({
                        msg: '操作成功',
                        duration: 2000,
                        location: 'bottom'
                    });
                    //操作成功后跳转到登录界面
                    setTimeout(function() {
                        ns.openWin('login_frm', '', {
                            id: '',
                        });
                    }, 200);
                } else if (err) {
                    api.toast({
                        msg: err,
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            });
        }
    }
});
apiready = function() {
    api.parseTapmode();
    ns = window.Foresight.Util;
    app.form.id = api.pageParam.id;
    // app.passwordtype=api.pageParam.passwordtype;
    //app.get_data();
};
